package com.ssh;

public class RemoveNthFromEnd_19 {
	public class ListNode {
		int val;
		ListNode next;
		ListNode(int x) { val = x; }
	}
	public ListNode removeNthFromEnd(ListNode head, int n) {
		ListNode ln = new ListNode(0);
		ln.next = head;
		ListNode s = ln,f = ln;
		for (int i = 0; i < n; i++) {
			f = f.next;
		}
		while (f.next != null) {
			f = f.next;
			s = s.next;
		}
		s.next = s.next.next;
        return ln.next;
    }
}
